Repository navigation
0.7.0: distribution tiers, encrypted packages and issued copies - #8
Merged
Merged
Conversation
added 30 commits
November 14, 2026 16:05
moca-spec package spec §4.1: PackageResult.distribution. The manifest's value, or open when absent; None when the manifest fails its schema. A label only. Bundled manifest schema updated; the conformance adapter outputs it. Refs openmoca/moca-spec#5
moca-spec encrypted packages §4. age v1 on cryptography (already a dependency): X25519 and scrypt recipients, no plugins, no armor. Strict header parsing, constant-time compares, and no plaintext before the whole payload authenticates. The core never imports it. Tested against every applicable C2SP age test vector (CCTV, vendored at b88c4b2; armored and hybrid vectors skipped) and against the Go age CLI on moca-spec's envelope fixtures. The moca-enc schema is bundled. Refs openmoca/moca-spec#5
moca-spec encrypted packages §2-§6. Envelopes are recognised by content in a Zip path or bytes, their entries and marker are checked, and they are opened in the order of §5.2 through read_package(decryptor=, key_provider=); the outline check runs right after the inner manifest is read; PackageResult.envelope; E001-E006, with the E family invalidating. The core never imports moca_reader.age. limits maxScryptWorkFactor (20). bind_envelope_sidecar() opens index.age the same way. The conformance adapter uses AGE_DECRYPTOR, so all 221 corpus cases run. Tests match the other Readers'; the no-file-writes test is stricter here, because Python falls back from an unwritable TMPDIR to /tmp. Refs openmoca/moca-spec#5
options.envelopeSidecar: bind_envelope_sidecar on the target envelope, for the corpus's envelope-index cases. All 224 cases pass. Refs openmoca/moca-spec#5
Package spec §4.6-4.8 (moca-spec#7) as in the reference Reader: M010-M013, limits["maxImageBytes"], the result fields images, translations and tags; the envelope cover copy and outline translations and tags. 249 corpus cases pass.
Package spec §4.9 (moca-spec#8) as in the reference Reader: apps in the package result, as declared, when the manifest passes its schema. Advice only; never fetched. 256 corpus cases pass.
…, record fields (moca-spec#5)
…sults, exact-size payload, stanza cap, fileKey accepted)
…tor limit when a read starts - An archive given as bytes, a bytearray or a memoryview is read in place, so the decrypted archive is not copied. It is zeroed once its entries have been read, for the package and for index.age. - An invalid limits["maxScryptWorkFactor"] is a ValueError when read_package or bind_envelope_sidecar starts. - identities: None is E002, as in the other Readers. - A custom decryptor's error is mapped by its kind only when that is a string. - Tests: no copy and zeroing, the limit at the start, null identities, and an unhashable kind.
- moca-reader, moca-reader-langchain and moca-reader-llamaindex at 0.7.0 (the bindings need moca-reader 0.7.0); MOCA_VERSION 0.7, contract version 0.7.0; CHANGELOG 0.7.0 section, dated 2026-11-15. - An opened envelope's result.source is None: its decrypted archive is zeroed once read, so there is nothing to read from. A test and the README say so. - README: archive bytes given as a target are read in place, so the host must not change them during the read. - The getting-started guide downloads from the v0.7.0 release. Until it exists, CI uses the v0.6.0 files, which are the same. - The MOCA_*_REF pins name the release-candidate commits; they move to v0.7.0 once tagged.
…ublishing Builds the three packages and publishes moca-reader first, then its bindings, with attestations. No PyPI token is kept. The package description now names moca-spec 0.7.
…binding by composition, upTo across members Media descriptions are exposed as node.media and never fetched; a time range on hosted media is checked against its transcript, and every time range must end within the media (latest cue end or declared duration). datePublished on the result and records. A composing package's structure binds its resolved members for concepts, scope and upTo; package states carry the bindings. isPartOf is core and R005 reports other undefined relation types. An issued copy matches a member pin, and binds the publisher's sidecar, through its verified original digest (S009). maxMembers defaults to 4,096. Schemas copied from moca-spec.
…§10) A member's records bound by composition to a concept are listed by nodes() for that concept, as the concepts and scope filters and upTo already treat them.
Frontmatter whose sources has two entries with the same id is C002_FRONTMATTER_INVALID, so the node is not read: evidence and media name a source by its id, so none is chosen. The Readers had disagreed on which entry applied.
… release candidates
… match on Windows
…e spec §5.7) Media descriptions may be alternates of a reference in the same node, lined up by a sync list of stretches. Invalid alternates are C005 and stand alone. A time range on an alternate with no transcript is checked through its reference's transcript. Records carry alternateOf and sync, and map_time maps a moment between alternates. Schemas copied from moca-spec.
… release candidates
…strings - Contract §3: a member met more than once in one read is resolved and read once, and shared. New limit maxMemberBytes (1 GiB, R001). - A reading order is walked once in list order with one visited set. - Bindings by composition keep only direct bindings and the structure links above them; a search walks down once from the concepts it needs. Package states carry that form. upTo limits members' records by their own concepts on every composer's order, bound or not. - A source whose id is not a string has no id in every lookup. - Budget tests for shared members, long reading orders and large bindings. - Library.search takes up_to.
… release candidates
… speak for - A media time range may carry a TextQuoteSelector as its refinedBy: it matches when the range does and the quote is in the covered cues, white space collapsed. evidence[].located gives the cue-precise span, also through alternates (contract §7). - A composer's reading order limits a member only when the composer's signers' ids cover the member's id, or the host allows unsigned packages (contract §9). Schemas copied from moca-spec.
… release candidates
… release candidates
… member repeats - A refined quote is located in linear time: the covered text is built once, one Knuth-Morris-Pratt pass finds every occurrence, and each span is constant time. located runs from the earliest start to the latest end of the touched cues; white space is the five ASCII characters. - An open-ended range on an alternate runs to the end of its stretch; a range must end within the alternate's own duration. - A repeat of a member id (M005) is not resolved; members are keyed by a structured id, version and digest. - .inf, .nan and numbers too large to be finite are neither numbers nor strings, and never fail a read. - Time-budget tests for refined quotes and member repeats.
… release candidates
…ge spec §12.1) The Reader recognises envelopes by content, so nothing depends on the names.
… release candidates
Pin every third-party action by full commit SHA, with its release as a comment, so a moved tag cannot change what runs. Dependabot keeps the pins current. Major versions are unchanged. The release build uses an exact uv, an exact twine, and exact versions of the build backend and its dependencies (.github/build-constraints.txt). Tests already install from uv.lock with uv sync --locked.
CI: pin actions by commit SHA; pin the release build tools
…elease candidate)
CI: 0.7.0 release candidate pins
… one pass - split_frontmatter reports any error from the YAML library as C002, not only YAML errors. - read_package keeps its promise never to raise for a malformed package: an error no check foresaw in a member leaves that member unresolved with one R001, and one in the read itself ends the read with one P002. - The nesting check before each JSON parse is a hand-written single pass that looks at each character once. Tests: a node with an escape past U+10FFFF in its front matter gives C002 and no exception; a forced error in a member gives one R001; a forced error in the read gives one P002; the nesting check on 1 MiB texts takes at most one step per character.
Contract §3: structure.ttl is nested at most 64 levels deep. The Turtle parser counts each blank-node property list or collection as one level as it reads, so the count follows Turtle's own rules for IRIs, strings, comments and names, and a 65th level is O001. The limit is set, not the interpreter's recursion limit: the parse runs on a thread of its own, so 64 levels are read however deep the caller's stack is. Tests: 64 levels read and 65 and 100,000 refused, for blank nodes, collections and both mixed; the same after an escaped name; brackets in a string or comment open nothing; 64 levels read from deep in the caller's stack; a package with 100,000 levels gives O001.
Front matter: every parser error is a diagnostic; JSON nesting check: one pass
…DR-0041) Byte for byte from moca-spec's schemas/v1: ai.allowed.mention at package level (a nodes entry's ai is nodeAi, without it), allowed.mention in a record's terms, and the new catalogue entry, registered as catalogueEntry.
…041) - allowed.mention: platform default true, resolved like every allowed.* field (the stricter applies whatever its authority); package level only, so a nodes entry's value is U003, has no effect and is never reported as loosened; a malformed value or container fails closed. - closure_of: whether a package is closed for a request's ai part, from its package-level resolved terms (no node level), with closedBy; hidden when closed and mention is not true. A use never closes a package. - A package with no terms result counts as mention false, as for every other permission.
…package (ADR-0041) - terms_gate: one view of each package's terms for a request, over a library or package states, shared by search, ingest, structure and the catalogue: each node's resolved terms, and whether its package is closed or hidden. - U004 carries excluded (records removed by reason) and hidden (how many came from packages hidden for the request), on the diagnostic and in to_json. - In a record from a search with a terms request, trust.supersededBy and trust.contestedBy leave out ids of hidden packages; superseded and contested keep their values. - Conformance adapter and the corpus test: termsExcluded on search cases; the catalogue case kind is checked as the runner checks it.
MemoryStoreBackend.ingest takes terms ({destination, conditions}, with the use embed) and the host's terms limits. Each unit's resolved terms are checked for the embedder's destination; a unit the gate removes is never sent to the embedder or written to the store, and the ingest reports U004 with its counts (ingest_diagnostics). Without a request, every unit is ingested, as before.
- structure_for(terms, terms_limits): the structure operations over the loaded packages not closed for the request, and the overlays; nodes returns records only from those packages. Without a request, or one with no ai part, the whole structure. - catalogue(terms, audiences, allow_unlabelled, include_all, terms_limits): an entry for each package with a record (its own or a member's, at any depth) that passes the audience set and the default retrieval policy, whose own rating passes the request's rating gate, and that is not hidden. A closed package's entry has exactly id, version, title, publisher, signed and closedBy; an open composite lists only members with an entry of their own. Ordered by id, then version. - Conformance adapter: options.terms on structure cases, options.ingestTerms on store searches, and the catalogue case kind. - Tests: the same as the reference Reader's terms-gate tests, including what a recording embedder receives at ingest.
… ingest too (ADR-0041) - Library.search gains terms and terms_limits, as Search has. - terms_request refuses an ai part that is not an object, so a binding never searches without one; destination is how an app says where its model runs. - ingest_terms: an ingest's terms request, destination provider unless the app declares device or host. - The LangChain and LlamaIndex packages gain ingest(store, library, destination=, conditions=, terms_limits=), which always passes a terms request; the LangChain retriever checks its request when it is built, as the LlamaIndex one already did.
…ds with ADR-0041; changelog MOCA_SPEC_REF bdb68a360f9ed82b5b0c3a37c017649323a01e59 and MOCA_READER_TYPESCRIPT_REF 81188bc91eb3d49ca4cfdca185423277c95241cc (0.7.0 release candidate; v0.7.0 once tagged). The 0.7.0 changelog says what the terms gate now covers.
What the terms gate covers, and hiding a closed package (moca-spec ADR-0041)
…elease candidate)
CI: pin the MOCA_*_REF commits to the heads of release-0.7.0 (0.7.0 release candidate)
The prefixes structure.ttl and host overlays declare are now found by a scanner that reads the text a line at a time, as the .NET Reader does. White space across several lines is read once, and the scan reports the steps it took. Tests: the scanner against the expression it replaces, on a table of @Prefix and PREFIX forms (case, comments, white space, IRIs, the empty prefix) and on random texts; and a step count, linear in the text, on 4 MiB of blank lines, of spaces and of repeated keywords.
Structure: prefix declarations are found in one pass
…idate) Moves MOCA_READER_TYPESCRIPT_REF (and MOCA_READER_PYTHON_REF where it is set) to the current head of that Reader's release-0.7.0, after the structure prefix scan fixes.
CI: pin the Readers to the heads of release-0.7.0 (0.7.0 release candidate)
CI: pin the MOCA_*_REF commits to the heads of release-0.7.0 (0.7.0 release candidate)
CI: pin MOCA_*_REF to the v0.7.0 tag commits
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements openmoca/moca-spec#5, #7, #8 and #9 for this repository, work package by work package on
release-0.7.0.distributionreadingOrderand the search optionupTo(Security baseline: CodeQL, gitleaks, OSV-Scanner, CycloneDX SBOM #9)Draft until every work package is in. Red CI runs are expected until the pins move.
Refs openmoca/moca-spec#5